package com.Sep_Three;

import java.util.Arrays;

/**
 * 646. 最长数对链
 */

public class Solution646 {
    public static int findLongestChain(int[][] pairs) {
        Arrays.sort(pairs,(a,b)->a[1]-b[1]);
        int res=1,temp=pairs[0][1];
        for (int i=1;i<pairs.length;i++)
        {
            if (pairs[i][0]>temp)
            {
                res++;
                temp=pairs[i][1];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int[][] res={{1,2}, {2,3}, {3,4}};
        System.out.println(findLongestChain(res));
    }
}
